<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/order_list.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/user/info.css')}}">
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.seller_nav')
        <div class="nav_right flr">
            <div class="base_content_box1 fl">
                <div class="box1_left fl">
                    <div class="img fl"><img src="{{empty($data['sp_logo'])?asset('/img/web/user/logo.png'):$data['sp_logo']}}"></div>
                    <div class="right_info">

                        <div class="name fl">{{$data['company']['company_name']}}
                            @if($data['company']['status']=='pass')
                                <font class="dq"><img src="{{asset('/img/web/user/rz_02.png')}}">已认证</font>
                            @else
                                <font class=""><img src="{{asset('/img/web/user/rz_01.png')}}">未认证</font>
                            @endif
                        </div>
                        <div class="time_box fl">
                            @if(in_array(1,$data['sp_type_id']))
                                <img title="合作商" src="{{asset('/img/web/user/he_02.png')}}">
                            @else
                                <img title="合作商" src="{{asset('/img/web/user/he_01.png')}}">
                            @endif
                            @if(in_array(2,$data['sp_type_id']))
                                <img title="经销商" src="{{asset('/img/web/user/jing_02.png')}}">
                            @else
                                <img title="经销商" src="{{asset('/img/web/user/jing_01.png')}}">
                            @endif
                            @if(in_array(2,$data['sp_type_id']))
                                <img title="旗舰店" src="{{asset('/img/web/user/qi_02.png')}}">
                            @else
                                <img title="旗舰店" src="{{asset('/img/web/user/qi_01.png')}}">
                            @endif
                            @if(!empty($data['company']['open_at']))
                                <span>开通时间：{{date('Y/m/d',strtotime($data['company']['open_at']))}}</span>
                            @endif
                        </div>
                        <div class="box1_nav fl">
                            <a target="_blank" href="{{url('/member/user/safe')}}">账号管理</a><font>|</font>
                            <a target="_blank" href="/member/user/companymaterial">完善资料</a><font>|</font>
                            <a target="_blank" href="/shop/index/{{session('user_shop_id')}}">我的商铺</a><font>|</font>
                            <a target="_blank" href="{{url('/member/seller/ejbao')}}">e井宝</a>
                        </div>
                    </div>
                    <div class="yuan1"></div>
                    <div class="yuan2"></div>
                </div>
                <div class="box1_right fr">
                    <h2>井信值</h2><a target="_blank" href="">了解井信值？</a>
                    <span>30</span>
                </div>
            </div>
            <div class="base_content_box2 fl">
                <div class="box2_info fl">
                    <h2>我的商铺</h2>
                    <span>完善公司信息，快速开店、挂货，更多商机等你!</span>
                    <div class="shop_box fl"><a class="shop_a" target="_blank" href="{{url('/member/seller/product/create')}}">发布商品</a></div>
                    <div class="shop_box fl"><a class="shop_a" target="_blank" href="{{url('/member/seller/design')}}">店铺装修</a></div>
                </div>
                <div class="box2_info fr">
                    <h2>项目配单</h2>
                    <span>项目清单完成券电子配单，还可以线上签约，下单交易！</span>
                    <div class="shop_box fl"><a class="shop_a" target="_blank" href="{{url('/member/seller/items/create')}}">发布配单</a></div>
                    <div class="shop_box fl"><a class="shop_a" target="_blank" href="{{url('/member/seller/items')}}">发报价（{{$data['items_count']}}）</a></div>
                </div>
                <div class="box2_info fl">
                    <h2>店铺商品</h2>
                    <div class="box2_center fl">
                        <a href="{{url('/member/seller/product?is_for_sale=1')}}" target="_blank">{{$data['sale']['sale_on']}}</a>
                        <font>在售商品</font>
                    </div>
                    <div class="box2_center fl">
                        <a href="{{url('/member/seller/product?is_for_sale=0')}}" target="_blank">{{$data['sale']['sale_down']}}</a>
                        <font>下架商品</font>
                    </div>
                </div>
                <div class="box2_info fr">
                    <h2>e井快讯</h2>
                    @foreach($data['article']['list'] as $article)
                        <a target="_blank" href="{{asset('/news/'.array_get($article,'id'))}}" class="information_a fl">{{$article['title']}}</a>
                    @endforeach
                    {{--<a target="_blank" class="information_a fl">从CCTV6走到CCTV5！梁朝伟帆船比赛获亚军</a>--}}
                    {{--<a target="_blank" class="information_a fl">从CCTV6走到CCTV5！梁朝伟帆船比赛获亚军</a>--}}
                </div>
            </div>
            <div class="base_content_box3 fl">
                 <h2>最新订单</h2>
                 <div class="table list">
                     <table>
                          <thead>
                          <tr>
                              <th width="300">
                                <p class="oedername">订单商品</p>
                              </th>
                              <th width="160">
                                <p>数量</p>
                              </th>
                              <th width="120">
                                <p>金额</p>
                              </th>
                              <th width="120">
                                <p>状态</p>
                              </th>
                              <th width="150">
                                <p>操作</p>
                              </th>
                          </tr>
                          </thead>
                      </table>
                 </div>
                 <div class="tablelist">
                     @foreach($data['order'] as $order)

                      <table>
                          <thead>
                          <tr>
                              <th>
                                <font>订单编号：<a target="_blank" href="/member/seller/orders/{{$order['id']}}">{{$order['order_code']}}</a></font>
                              </th>
                              <th colspan="3">

                              </th>
                              <th width="150">
                                <span>下单时间：{{date('Y/m/d', strtotime($order['created_at']))}}</span>
                              </th>
                          </tr>
                          </thead>
                          <tbody>
                          @if($order['order_type']==1 || $order['order_type']==6)

                              @foreach($order['order_products'] as $key => $order_product)
                                  <tr>
                                      <td width="300">
                                          @if($order['order_type']==1)
                                            <a class="img" target="_blank" href="/product/info/{{$order_product['product_id']}}/{{$order_product['sku_id']}}">
                                              <img width="70" height="70" src="{{$order_product['product_img_url']}}">
                                            </a>
                                            <span class="goodsname">
                                              <a target="_blank" href="/product/info/{{$order_product['product_id']}}/{{$order_product['sku_id']}}">{{$order_product['product_name']}}</a>
                                            </span>
                                          @else

                                              <a class="img" ><img width="70" height="70" src="{{$order_product['product_img_url']}}"></a>

                                              <span class="goodsname">
                                                  {{$order_product['product_name']}}
                                              </span>
                                          @endif
                                      </td>
                                      <td class="text-center" width="160">
                                          <p>{{$order_product['quantity']}}</p>
                                      </td>
                                      <td class="text-center" width="120">¥{{$order_product['product_price']}}</td>
                                      <td class="text-center" width="120">

                                        <p>{{$order['order_status_name']}}</p>
                                        <p><a target="_blank" href="/member/seller/orders/{{$order['id']}}">订单详情</a></p>
                                      </td>
                                      <td class="text-center" width="150">
                                          @if($order['order_status']==1)
                                              <div class="btn_delivery modify_price" data-id='{{$order["id"]}}'>修改价格</div>
                                              <div class="btn_delivery trade_close" data-id='{{$order["id"]}}'>关闭交易</div>
                                          @elseif($order['order_status']==2)
                                              <div class="btn_delivery revise_price shipments_btn" data-id='{{$order["id"]}}'>发货</div>
                                          @elseif($order['order_status']==3)
                                              <!-- <div class="btn_delivery" data-id='{{$order["order_code"]}}'>确认收货</div> -->
                                              等待买家确认收货
                                          @elseif($order['order_status']==4)
                                              交易完成
                                              <div class="btn_delivery revise_evaluate" data-id='{{$order["id"]}}'>{{$order['seller_comment_status'] ? '查看评价' : '评价'}}</div>
                                          @elseif($order['order_status']==5)
                                              已取消
                                          @endif
                                      </td>
                                  </tr>

                              @endforeach
                          @elseif($order['order_type']==4)
                              @foreach($order['items_products'] as $key => $items_product)
                                <tr>
                                    <td width="300">
                                      <div class="productname" title="{{$items_product['product_name']}}">
                                          {{$items_product['product_name']}}
                                      </div>

                                      <span class="goodsname">
                                          {{$items_product['model']}} {{$items_product['brand']}}
                                      </span>
                                    </td>
                                    <td class="text-center" width="160">
                                        <p>{{$items_product['num']}}</p>
                                    </td>
                                    <td class="text-center" width="120">¥{{$items_product['price']}}</td>
                                    <td class="text-center" width="120">

                                      <p>{{$order['order_status_name']}}</p>
                                      <p><a target="_blank" href="/member/seller/orders/{{$order['id']}}">订单详情</a></p>
                                    </td>
                                    <td class="text-center" width="150">
                                        @if($order['order_status']==1)
                                            <div class="btn_delivery trade_close" data-id='{{$order["id"]}}'>关闭交易</div>
                                        @elseif($order['order_status']==2)
                                            <div class="btn_delivery revise_price shipments_btn" data-id='{{$order["id"]}}'>发货</div>
                                        @elseif($order['order_status']==3)
                                            <!-- <div class="btn_delivery" data-id='{{$order["order_code"]}}'>确认收货</div> -->
                                            等待买家确认收货
                                        @elseif($order['order_status']==4)
                                            交易完成
                                            <div class="btn_delivery revise_evaluate" data-id='{{$order["id"]}}'>{{$order['seller_comment_status'] ? '查看评价' : '评价'}}</div>
                                        @elseif($order['order_status']==5)
                                            已取消
                                        @endif
                                    </td>
                                </tr>

                                @endforeach

                          @endif
                          </tbody>
                      </table>
                     @endforeach

                  </div>
            </div>
        </div>
    </div>
</div>
<div class="bg_h"></div>

{{--发货--}}
<!-- include('web.user.seller.common.shipments', ['express_company' => $express_company]) -->
@include('web.user.seller.common.shipments', ['express_company' => $express_company])


{{--改价--}}
<div class="revise_price_bombbox">
    <form action='' id="change-price-form">

    </form>
</div>

{{--评价--}}
<div class="revise_evaluate_bombbox" id='evaluate_bombbox'>
</div>

{{--关闭订单--}}
<div class="trade_close_bombbox">
</div>
@include('web.layout.footer')
</body>
<script>
    $(function (e) {
        var member_img = null ;
        // 图片上传
        $('#js-photo-upload').change(function(){
            var url = AJAX_URL + '/uploads/images';
            var files =  this.files[0];
            var formFile = new FormData();
            formFile.append("image", files);
            $.ajax({
                url: url,
                type: "POST",
                data: formFile,
                contentType: false,
                cache: false,
                processData: false,
                // 显示加载图片
                success: function (res) {
                    if (res.status == 0){
                        $(".uploaded-image").attr('src',res.path);
                        $('input[name="img_path"]').val(res.path);

                    } else {
                        layer.alert('图片上传失败', {
                            title:'提示',
                            icon: 2
                        });
                    }
                },
                error: function () { }
            });
        })
        $(".avatar_edit").click(function () {
            $("#js-photo-upload").trigger("click");

        });



        $(".avatar").hover(function () {
            $('.avatar_edit').show();
        }, function(){
            $('.avatar_edit').hide();
        });


        $('.js-save-member').click(function () {
            var sex = $('input[name="sex"]:checked').val();
            var pic_path = $('input[name="img_path"]').val();
            var token = $('input[name="_token"]').val();
            var url = AJAX_URL + '/member/user/updateinfo';

            $.get(url, {path: pic_path, sex: sex, _token: token}, function (res) {
                if (res.code == 0) {
                    layer.alert('信息更新成功', {
                        icon: 1
                    });
                } else {
                    layer.alert(res.message, {
                        icon: 2
                    });
                }
            }, 'json')
        })

        var level = $('#level').val();
        $('.level span').css("width",level*100+'%');
        if(level == 0){
            $('.level_word').html('较低');
        }else if(level ==0.5 ){
            $('.level_word').html('中等');
        }else if(level == 1 ){
            $('.level_word').html('完善');
        }
    })
    var change_price_url = '/member/seller/orders/{id}/order_products/0/edit';
    var comment_url = '/member/seller/orders/{id}/user_comment/0';
    var order_update_edit = '/member/seller/orders/{id}/edit';
//    $(function(){
        //修改价格
    $('.modify_price').click(function(){
        var id = $(this).data('id');
        var url = change_price_url.replace('{id}', id);
        $.ajax({
            url: url,
            type: 'get',
            dataType: 'html',
            success: function (data) {

                $('.revise_price_bombbox form').html(data);
                $('.revise_price_bombbox').show();
                $('.bg_h').show();
            }
        });
    });

    //发货
    $('.shipments_btn').click(function(){
        var order_id = $(this).data('id');
        $('.express_confirm').data('id', order_id);
        $('.delivery_bombbox').show();
        $('.bg_h').show();
    });

    //评价
    $('.revise_evaluate').click(function(){
        var order_id = $(this).data('id');
        var url = comment_url.replace('{id}', order_id);
        $.ajax({
            url: url,
            type: 'get',
            dataType: 'html',
            success: function (data) {
                $('.revise_evaluate_bombbox').html(data);
                $('.revise_evaluate_bombbox').show();
                $('.bg_h').show();
            }
        });
    });

    //确定关闭交易
    $(".trade_close").on('click', function(event) {
        var order_id = $(this).data('id');
        var url = order_update_edit.replace('{id}', order_id);
        $.ajax({
            url: url,
            type: 'get',
            dataType: 'html',
            success: function (data) {
                $('.trade_close_bombbox').html(data);
                $('.trade_close_bombbox').show();
                $('.bg_h').show();
            }
        });


    });
//    });
</script>
</html>